package com.example.dllo.baidumusic.adapter;
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.dllo.baidumusic.R;
import com.example.dllo.baidumusic.bean.HotSingBean;
import com.example.dllo.baidumusic.bean.SingListIdBean;
import com.example.dllo.baidumusic.nettool.NetTool;

/**
 * Created by dllo on 16/8/22.
 */
public class SingListAdapter extends BaseAdapter {
    private SingListIdBean listIdBean;
    Context mContext;

    public SingListAdapter(Context mContext) {
        this.mContext = mContext;
        notifyDataSetChanged();
    }

    public void setListIdBean(SingListIdBean listIdBean) {
        this.listIdBean = listIdBean;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        int a = 0;
        if (listIdBean.getContent() != null) {
            a = listIdBean == null ? 0 : listIdBean.getContent().size();
        }
        return a;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHoler viewHoler = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_singlist, parent, false);
            viewHoler = new ViewHoler(convertView);
            convertView.setTag(viewHoler);
        } else {
            viewHoler = (ViewHoler) convertView.getTag();
        }


        viewHoler.author.setText(listIdBean.getContent().get(position).getTitle());
        viewHoler.title.setText(listIdBean.getContent().get(position).getAuthor());

//        NetTool netTool = new NetTool();
//        netTool.getImage(hotSingBean.getSong_list().get(position).getPic_big(), viewHoler.img);


        return convertView;
    }

    public class ViewHoler {

        //        ImageView img;
        TextView title;
        TextView author;

        public ViewHoler(View convertView) {

//            img = (ImageView) convertView.findViewById(R.id.item_hotsing_img);
            title = (TextView) convertView.findViewById(R.id.item_tujisinglist_singer);
            author = (TextView) convertView.findViewById(R.id.item_tujisinglist_singname);


        }
    }
}